import http from '../utils/request';


// 响应接口
interface defalutRes {
	code : number;
	data : string;
	msg : string;
}

// 查询服务项目
export function getServiceList(params : {
	"serviceType" ?: number | string,
	"status" ?: string,
	"tyjPageNum" : number,
	"tyjPageSize" : number
}) : Promise<GetServiceListRes> {
	return http('/api/auth/mer/serviceInfo/getServiceList', params, 'POST') as any
}

// 参数接口
interface CreateParams {
	businessType ?: number;
	id ?: string;
	keyword ?: string;
	price ?: number;
	serviceName ?: string;
	serviceStatus ?: number;
	sortNum ?: number;
}


// 添加服务项目
export function serviceInfoCreate(params : CreateParams) : Promise<defalutRes> {
	return http('/api/auth/mer/serviceInfo/create', params, 'POST') as any
}

// 删除服务项目
export function serviceInfoDelete(params : { id : string | number }) : Promise<defalutRes> {
	return http('/api/auth/mer/serviceInfo/delete', params, 'POST') as any
}
// 响应接口
interface ServiceInfoDetailRes {
	code : number;
	data : {
		createTime : Record<string, unknown>;
		id : string;
		keyword : string;
		merId : string;
		price : number;
		serviceName : string;
		serviceStatus : number;
		serviceType : number;
		sortNum : number;
		updateTime : Record<string, unknown>;
		serviceTypeLabel ?: string
	};
	msg : string;
}

// 查询服务项目明细
export function serviceInfoDetail(params : { id : string }) : Promise<ServiceInfoDetailRes> {
	return http('/api/auth/mer/serviceInfo/detail', params, 'POST') as any
}

interface defalutPrams {
	"tyjPageNum" : number,
	"tyjPageSize" : number

}

// 接车开单

interface OrderCreateParams {
	archiveFileList ?: any[];
	customerName ?: string;
	detailList ?: {
		nums ?: Record<string, unknown>;
		serviceId ?: string;
	}[];
	mileage ?: number;
	oil ?: number;
	payChannel ?: number;
	phone ?: string;
	remark ?: string;
	sourceChannel ?: string;
	sourceChannelName ?: string;
	vno ?: string;
}

export function orderCreate(params : OrderCreateParams) : Promise<defalutRes> {
	return http('/api/auth/mer/order/create', params, 'POST') as any
}

// 工单查询
export function orderQuery(params : GetOrderQueryListParams) : Promise<GetOrderQueryListRes> {
	return http('/api/auth/mer/order/query', params, 'POST') as any
}
// 工单详情
export function orderDetail(params : { id : string }) : Promise<OrderDetailRes> {
	return http('/api/auth/mer/order/detail', params, 'POST') as any
}
// 工单作废
export function orderCancel(params : { id : string, remark ?: string }) : Promise<defalutRes> {
	return http('/api/auth/mer/order/cancel', params, 'POST') as any
}



// 查询开单渠道管理
export function getSourceChannelList(params : defalutPrams) : Promise<GetSourceChannelListRes> {
	return http('/api/auth/mer/sourceChannel/getSourceChannelList', params, 'POST') as any
}
// 添加-编辑开单渠道
export function createOrUpdate(params : {
	"channelName" : string,
	"id" ?: string,
	"sortNum" ?: number
}) : Promise<defalutRes> {
	return http('/api/auth/mer/sourceChannel/createOrUpdate', params, 'POST') as any
}
// 删除开单渠道
export function sourceChannelDelete(params : { id : string }) : Promise<defalutRes> {
	return http('/api/auth/mer/sourceChannel/delete', params, 'POST') as any
}
// 添加-编辑客户
export function customerCreateOrUpdate(params : {
	id ?: string;
	mobile : string;
	sex ?: string;
	userId ?: string;
	userName ?: string;
	vno ?: string;
}) : Promise<defalutRes> {
	return http('/api/auth/mer/customer/createOrUpdate', params, 'POST') as any
}
//  查询客户详情

interface GetDetailRes {
	code : number;
	data : {
		accountAmount : number;
		id : string;
		merOrderAmount : number;
		merOrderCount : number;
		mobile : string;
		nickName : string;
		payOrderAmount : number;
		payOrderCount : number;
		platformOrderAmount : number;
		platformOrderCount : number;
		sex : string;
		userHeadUrl : string;
		userId : string;
		userName : string;
		vip : number;
		vno : string;
		remark : string;
		birthDay : string;
		
	};
	msg : string;
}

export function customerDetail(params : {
	"id" : string,
	"userId" : string
}) : Promise<GetDetailRes> {
	return http('/api/auth/mer/customer/detail', params, 'POST') as any
}


// 查询开单客户列表(接车开单选择客户使用)
export function getOrderCustomerList(params : {
	"keyword" : string,
	"tyjPageNum" : number,
	"tyjPageSize" : number
}) : Promise<GetOrderCustomerListRes> {
	return http('/api/auth/mer/customer/getOrderCustomerList', params, 'POST') as any
}


/** 
 * 经营报表-员工统计
 * @param {object} params req
 * @param {string} params.businessType 类型 [10003002:洗车 ,10003003:美容 ,10003006/7:小保养/机油 ,10003011:检测站 ]
 * @param {string} params.endTime 截止时间: yyyy-mm-dd hh:mm:ss
 * @param {string} params.startTime 开始时间: yyyy-mm-dd hh:mm:ss
 * @returns
 */

interface GetStoreManagementStaffReportRes {
  code: number;
  msg: string;
  pageNum: number;
  pageSize: number;
  rows: {
    incomeAmount: number;
    staffName: string;
    staffUserId: string;
    useAmount: number;
    useOrderCount: number;
    userHeadUrl: string;
  }[];
  total: number;
}

export function getStoreManagementStaffReport(params : {
	businessType ?: string,
	"endTime" : string,
	"startTime" : string
}) : Promise<GetStoreManagementStaffReportRes> {
	return http('/api/auth/mer/store/getStoreManagementStaffReport', params, 'POST') as any
}